package answer.service.Impl;

import answer.mapper.AnsMapper;
import answer.service.AnsService;
import commons.pojo.Ans;
import commons.vo.LivegoodsResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AnsServiceImpl implements AnsService {
    @Autowired
    private AnsMapper ansMapper;

    @Override
    public LivegoodsResult selectAns(int id) {
        Ans ans = ansMapper.selectById(id);
        return LivegoodsResult.ok(ans);
    }

    @Override
    public LivegoodsResult updateAns(Ans ans) {
        Ans ans1 = ansMapper.selectById(ans.getId());

        ansMapper.updateById(new Ans(ans.getId(),ans.getDay()+ans1.getDay(),ans.getDaygood()+ans1.getDaygood(),ans.getWeek()+ans1.getWeek(),ans.getWeekgood()+ans1.getWeekgood(),ans.getSp()+ans1.getSp(),ans.getSpgood()+ans1.getSpgood(),ans.getTiao()+ans1.getTiao(),ans.getTiaogood()+ans1.getTiaogood(),ans.getXian()+ans1.getXian(),ans.getXiangood()+ans1.getXiangood(),ans.getCount()+ans1.getCount()));
        return LivegoodsResult.ok();
    }
}
